#include <cstdio>
#include <cstring>

int main( )
{
    int i = 1, j, t, f[ 25 ], num1[ 26 ], num2[ 26 ];
    char data1[ 300 ], data2[ 300 ];
    bool cor;
    for ( t = 0; t < 25; t++ )
    {
        cor = false;
        while ( !cor )
        {
            i++;
            for ( j = 2; j <= i / 2; j++ )
                if ( i % j == 0 )
                    break;
            if ( j > i / 2 )
                cor = true;
        }
        f[ t ] = i;
    }
    while ( scanf("%s%s", data1, data2) != EOF )
    {
        if ( strcmp( data1, "0" ) == 0 && strcmp( data2, "0" ) == 0 )
            break;
        for ( i = 0; i < 26; i++ )
            num1[ i ] = num2[ i ] = 0;
        t = 0;
        j = 1;
        for ( i = strlen( data1 ) - 1; i >= 0; i-- )
            if ( data1[ i ] != ',' )
            {
                num1[ t ] += j * ( data1[ i ] - '0' );
                j *= 10;
            }
            else
            {
                t++;
                j = 1;
            }
        t = 0;
        j = 1;
        for ( i = strlen( data2 ) - 1; i >= 0; i-- )
            if ( data2[ i ] != ',' )
            {
                num2[ t ] += j * ( data2[ i ] - '0' );
                j *= 10;
            }
            else
            {
                t++;
                j = 1;
            }
        for ( i = 0; i < 25; i++ )
        {
            num1[ i ] += num2[ i ];
            if ( num1[ i ] >= f[ i ] )
            {
                num1[ i ] -= f[ i ];
                num1[ i + 1 ]++;
            }
        }
        cor = false;
        for ( i = 25; i >= 0; i-- )
        {
            if ( cor )
                printf(",%d", num1[ i ]);
            else
                if ( num1[ i ] )
                {
                    printf("%d", num1[ i ]);
                    cor = true;
                }
        }
        printf("\n");
    }
    return 0;
}
